package com.ev.asl.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ev.asl.constant.AslConstant;
import com.ev.asl.dao.CheckResultDao;
import com.ev.asl.dao.CheckResultDetailDao;
import com.ev.asl.domain.CheckResultDO;
import com.ev.asl.domain.CheckResultDetailDO;
import com.ev.asl.dto.CheckResultDto;
import com.ev.asl.service.AssemblyDailyService;
import com.ev.asl.service.CheckResultService;
import com.ev.asl.service.MoldingDailyService;
import com.ev.asl.vo.*;
import com.ev.custom.service.DailyReportService;
import com.ev.custom.service.NoticeService;
import com.ev.framework.config.Constant;
import com.ev.framework.config.ConstantForMES;
import com.ev.framework.utils.*;
import com.ev.mes.service.CheckProjectService;
import com.ev.system.domain.UserDO;
import com.ev.system.service.UserService;
import com.google.common.collect.Maps;
import com.googlecode.aviator.AviatorEvaluator;
import com.googlecode.aviator.Expression;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestParam;

import java.io.IOException;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author 姚家乐
 * @since 2021/6/18 12:59
 */
@Service
@Slf4j
public class CheckResultServiceImpl implements CheckResultService {

    @Autowired
    private CheckResultDao       dao;
    @Autowired
    NoticeService noticeService;
    @Autowired
    private DailyReportService dailyReportService;


    @Autowired
    private CheckResultDetailDao detailDao;
    @Autowired
    private UserService userService;
    @Autowired
    private CheckProjectService checkProjectService;

    @Override
    public Integer save(CheckResultDO entity) {
        return dao.save(entity);
    }

    @Override
    @Transactional
    public Integer save(CheckResultDto dto) {

        String prefix = DateFormatUtil.getWorkOrderno(ConstantForMES.CHECK_PLAN_JCCJ, new Date());
        Map<String, Object> params = Maps.newHashMapWithExpectedSize(3);
        params.put("checkNo", prefix);
        params.put("offset", 0);
        params.put("limit", 1);
        List<CheckResultDO> checkResultDOList = dao.list(params);
        String suffix = null;
        if (checkResultDOList.size() > 0) {
            suffix = checkResultDOList.get(0).getCheckNo();
        }
        dto.setCheckNo(DateFormatUtil.getWorkOrderno(prefix, suffix));
        UserDO userDO = ShiroUtils.getUser();
//        dto.setQualityInspectorId(userDO.getUserId());
//        dto.setQualityInspectorName(userDO.getName());
        dto.setStatus(AslConstant.NO);
        dto.setDelFlag(AslConstant.NO);


//        if (AslConstant.ONE.equals(dto.getIsChooseShow())){
//            MoldingDailyDO moldingDailyDO = moldingDailyService.get(dto.getDailyId());
//            dto.setProductionDate(moldingDailyDO.getIndicateDate());
//        }
//        if (AslConstant.TWO.equals(dto.getIsChooseShow())){
//            AssemblyDailyDO assemblyDailyDO = assemblyDailyService.get(dto.getDailyId());
//            dto.setProductionDate(assemblyDailyDO.getIndicateDate());
//        }

        CheckResultDO entity = new CheckResultDO();
        SpringUtils.copyPropertiesIgnoreNull(dto, entity);
        int result = dao.save(entity);
        if (result > AslConstant.ZERO) {
            List<Map> maps = JSON.parseArray(dto.getDetailDOS(), Map.class);
            if (ObjectUtils.isEmpty(maps)){
                return AslConstant.ZERO;
            }
            List<CheckResultDetail2VO> detailDOS = this.mapCreateDoMain(maps);
            for (CheckResultDetail2VO detailDO : detailDOS) {
                detailDO.setMainId(entity.getId());
            }
//            detailDao.batchSave(detailDOS);
            dto.setId(entity.getId());
            return result;
        }
        return AslConstant.ZERO;
    }

    /**
     *
     * @param dto
     * @param type 1:成型，2：组装
     * @return
     */
    @Override
    @Transactional
    public Integer save2(CheckResultDto dto, Integer type) {
        log.error("==================================4");
        Map<String, Object> params2 = Maps.newHashMapWithExpectedSize(5);
        params2.put("materielId", dto.getProductId());
        List<CheckResultDetail2VO> checkProjects = checkProjectService.list3(params2);
        if (ObjectUtils.isEmpty(checkProjects)){
            return AslConstant.ZERO;
        }

        List<CheckResultDetailDO> detailDOS = new ArrayList<>();
        String prefix = DateFormatUtil.getWorkOrderno(ConstantForMES.CHECK_PLAN_JCCJ, new Date());
        Map<String, Object> params = Maps.newHashMapWithExpectedSize(3);
        params.put("checkNo", prefix);
        params.put("offset", 0);
        params.put("limit", 1);
        List<CheckResultDO> checkResultDOList = dao.list(params);
        String suffix = null;
        if (checkResultDOList.size() > 0) {
            suffix = checkResultDOList.get(0).getCheckNo();
        }
        UserDO userDO = ShiroUtils.getUser();



//        dto.setQualityInspectorId(userDO.getUserId());
//        dto.setQualityInspectorName(userDO.getName());
        dto.setStatus(AslConstant.NO);
        dto.setDelFlag(AslConstant.NO);
        dto.setProductionDate(new Date());
        if (type.equals(1)){
            dto.setGroup(0);
        }

        CheckResultDO entity = new CheckResultDO();
        SpringUtils.copyPropertiesIgnoreNull(dto, entity);
        if (type.equals(1)){
            entity.setGroup(0);
        }
        entity.setCheckNo(DateFormatUtil.getWorkOrderno(prefix, suffix));
        int result = dao.save(entity);

        if (result <= AslConstant.ZERO) {
            return AslConstant.ZERO;
        }

        checkProjects.forEach(check -> {
            CheckResultDetailDO detailDO = new CheckResultDetailDO();
            detailDO.setCheckItemId(check.getCheckItemId());
            detailDO.setCheckTypeId(check.getCheckTypeId());
            detailDO.setSample(check.getSample());
            if (!Constant.QIMI.equals(check.getCheckItem())){
                detailDO.setSample(check.getSample());
            }
            detailDO.setCheckItem(check.getCheckItem());
            detailDO.setCheckWay(check.getCheckWay());
            detailDO.setFormula(check.getFormula());
            detailDO.setSize(check.getSize());
            detailDO.setSpecification(check.getSpecification());
            detailDO.setMainId(entity.getId());
            detailDOS.add(detailDO);
        });
        detailDao.batchSave(detailDOS);
        this.sendCheckMessage(entity.getId());

        dto.setId(entity.getId());
        return result;
    }

    @Override
    public void sendCheckMessage(Long dailyReportId){
        HashMap<String, Object> userMap = new HashMap<>();
        userMap.put("deptId",Constant.QUALITY_DEPT);
        List<UserDO> list = userService.list(userMap);
        if (Objects.isNull(list)){
            return;
        }
        if (list.contains(Constant.QUALITY_DEPT_MANAGER)) list.remove(Constant.QUALITY_DEPT_MANAGER);
        if (Objects.isNull(list)){
            return;
        }
        List<Long> toUsers = list.stream().filter(userDO -> userDO.getUserId()!=271).map(UserDO::getUserId).collect(Collectors.toList());
        String comment = "您好,"+ShiroUtils.getUser().getName()+"的检查成绩单已生成，请及时检验";
        dailyReportService.commentDailyReport(dailyReportId, comment);
        JSONObject contentDetail = new JSONObject();
        contentDetail.put("id",dailyReportId);
        contentDetail.put("url","/basic/check_grade_add?id="+dailyReportId+"&status=0");
        try {
            noticeService.saveAndSendSocket("新增检查成绩单",comment,dailyReportId,contentDetail.toString(),8L,ShiroUtils.getUserId(),toUsers);
        } catch (IOException e) {
            log.error("==============================发送检查成绩的提醒消息失败。id:"+dailyReportId);
            e.printStackTrace();
        } catch (ParseException e) {
            log.error("==============================发送检查成绩的提醒消息失败。id:"+dailyReportId);
            e.printStackTrace();
        }
    }
    @Override
    @Transactional
    public R check(CheckResult3VO checkResult3VO) {
        List<CheckResultDetail2VO> detailVOS = checkResult3VO.getDetailVOS();
        if (ObjectUtils.isEmpty(detailVOS)){
            return R.error("检查项目为空");
        }
        List<CheckResultDetail2VO> collect = detailVOS.stream().
                filter(detail -> !ObjectUtils.isEmpty(detail.getFormula()) && !ObjectUtils.isEmpty((detail.getCheckValue())))
                .collect(Collectors.toList());

        CheckResultDO entity = new CheckResultDO();
        Integer result = caculate(collect);
        entity.setResult(result);
        entity.setId(checkResult3VO.getId());
        entity.setResult(result);
        dao.update(entity);
        if (ObjectUtils.isEmpty(collect)){
            return R.ok();
        }
        detailDao.batchUpdate(collect);
        return R.ok();
    }

    public static void main(String[] args) {
//        String expression = "(((((a > b) ? a : b)> c) ? (a > b) ? a : b) : c) * 3.08 / 200 )<10";
//        String expression = "((((a > b) ? a : b)> c) ? (a > b) ? a : b) : c)";
//        String expression = "(((((a > b) ? a : b) > c ) ? ((a > b) ? a : b) : c) * 3.08 / 200 )<10";
//        String expression = "((((a > b) ? a : b) > c ) ? ((a > b) ? a : b) : c) * 3";
//        String expression = "a != 0  || b != 0 ";
//        String expression = "a>=58.4 && a<=59.6 && b>=58.4 && b<=59.6 && average>=58.4 && average<=59.6";
        // 编译表达式
        String expression = "a>=58.4 && a<=59.6 && b>=58.4 && b<=59.6 && average>=58.4 && average<=59.6";
//        String expression = "a>=58.4 && a<=59.6 && b>=58.4 && b<=59.6";
//        String expression = "a>=58.4 && a<=59.6";
        Expression compiledExp = AviatorEvaluator.compile(expression);

        Map<String, Object> env = new HashMap<String, Object>();
        env.put("a", 58.8);
        env.put("b", 58.4);
        ArrayList<BigDecimal> decimals = new ArrayList<>();
        decimals.add(new BigDecimal(58.8));
        decimals.add(new BigDecimal(58.4));
        BigDecimal average = decimals.stream().collect(CustomCollectors.averagingBigDecimal(i -> new BigDecimal(i.toString()), 2, 2));

        // 执行表达式
//        String result = (Boolean)execute ? "合格" : "不合格";
        env.put("average", 59);
        Object execute = compiledExp.execute(env);
        System.out.println(JSON.toJSONString(execute));
    }
    public Integer caculate(List<CheckResultDetail2VO> checkResultDetail2VOS) {
        checkResultDetail2VOS.forEach(detail ->{
            detail.setCheckValue2(JSON.toJSONString(detail.getCheckValue()));
            List<BigDecimal> values = detail.getCheckValue().stream().filter(val -> !ObjectUtils.isEmpty(val)).collect(Collectors.toList());
            BigDecimal average = values.stream().collect(CustomCollectors.averagingBigDecimal(i -> new BigDecimal(i.toString()), 2, 2));
            BigDecimal min = values.stream().collect(CustomCollectors.minBy(i -> new BigDecimal(i.toString())));
            Expression compiledExp = AviatorEvaluator.compile(detail.getFormula());
            Map<String, Object> env = new HashMap<>();
            Object execute = null;
            env = new HashMap<String, Object>();
            String typeName = detail.getTypeName()==null ? "" : detail.getTypeName();//检验类型
            switch (typeName) {
                case "颗粒物测定"://  (((((a > b) ? a : b) > c ) ? ((a > b) ? a : b) : c) * 3.08 / 200 ) <= 10   =>   (a * 77 / 10000 ) <= 10
                    env.put("average", average);
                    env.put("a", detail.getCheckValue().get(0));
//                    env.put("b", detail.getCheckValue().get(1));
//                    env.put("c", detail.getCheckValue().get(2));
                    break;
                case Constant.ZHURUKOU://a>=58.4 && a<=59.6 && b>=58.4 && b<=59.6 && average>=58.4 && average<=59.6
                    env.put("a", detail.getCheckValue().get(0));
                    env.put("b", detail.getCheckValue().get(1));
                    env.put("average", average);
                    break;
                case "厚度"://min >= 3.5
                    env.put("min", min);
                    break;
                case "高度":// average <= 985 && average>=975
                    env.put("average", average);
                    break;
                case "宽度"://average <= 595 && average >= 585
                    env.put("average", average);
                    break;
                case "重量":// average <= 13.5 && average >=12.5
                    env.put("average", average);
                    break;
                case "容积":// average >= 200
                    env.put("average", average);
                    break;
                case "检查":// 0-合格；1-不合格   result == 0
                    env.put("result", detail.getCheckValue().get(0));
                    break;
                default:
                    break;
            }
            execute = compiledExp.execute(env);
            String result = (Boolean)execute ? "合格" : "不合格";
            detail.setCheckResult(result);
        });
        List<CheckResultDetail2VO> collect = checkResultDetail2VOS.stream().filter(result->!("0.1 ㎛ ≤ particle".equals(result.getSize()) || "0.2 ㎛ ≤ particle".equals(result.getSize()))).filter(result -> result.getCheckResult().equals("不合格")).collect(Collectors.toList());
        if (ObjectUtils.isEmpty(collect)){
            return 0;
        }
        return 1;
    }

    private List<CheckResultDetail2VO> mapCreateDoMain(List<Map> maps) {
        List<CheckResultDetail2VO> detailDOS = new ArrayList<>();
        for (Map map : maps) {
            CheckResultDetail2VO detailDO = new CheckResultDetail2VO();
//            detailDO.setCheckResult(String.valueOf(map.get("remark")));
            detailDO.setRemarks(String.valueOf(map.get("remarks")));
            detailDO.setId(new Long(map.get("id").toString()));
//            detailDO.setCheckItem(String.valueOf(map.get("name")));
//            detailDO.setCheckItemId(Long.valueOf(String.valueOf(map.get("projectId"))));
//            detailDO.setCheckTypeId(map.get("typeDictionaryId") != null ? Long.parseLong(String.valueOf(map.get("typeDictionaryId"))) : null);
////            detailDO
////                .setCheckValue(new BigDecimal(map.get("checkValue") != null ? String.valueOf(map.get("checkValue"))
////                    : "0"));
            detailDO
                .setCheckValue2(map.get("checkValue") != null ? String.valueOf(map.get("checkValue"))
                    : null);
            detailDO.setCheckWay(map.get("checkWay") != null ? String.valueOf(map.get("checkWay")) : null);
            detailDO
                .setSpecification(map.get("specification") != null ? String.valueOf(map.get("specification"))
                    : null);
//            detailDO.setSpecification(ObjectUtils.isEmpty(map.get("projectNorm")) ? null : String.valueOf(map.get("projectNorm")));

//            detailDO.setFormula(ObjectUtils.isEmpty(map.get("projectFormula")) ? null : String.valueOf(map.get("projectFormula")));
            detailDO.setSample(String.valueOf(map.get("sample")));
            detailDO.setMode(String.valueOf(map.get("mode")));
            detailDO.setStatusValue(String.valueOf(map.get("statusValue")));
            detailDO.setCheckResult(String.valueOf(map.get("checkResult")));
//            detailDO
//                .setTargetValue(new BigDecimal(map.get("targetValue") != null ? String.valueOf(map.get("targetValue"))
//                    : "0"));
//            detailDO.setCheckWay(map.get("method") != null ? String.valueOf(map.get("method")) : null);
            detailDOS.add(detailDO);
        }
        return detailDOS;
    }

    @Override
    public CheckResultDO get(Long id) {
        return dao.get(id);
    }

    @Override
    public Map<String, Object> getDetailInfo(Long id) {
         Map<String, Object> result = dao.getDetailInfo(id);
        if (Objects.nonNull(result)) {
            result.put("billDate", DateUtils.format((Date) result.get("billDate"),DateUtils.DATE_TIME_PATTERN));
            result.put("product",ObjectUtils.isEmpty(result.get("specification")) ? result.get("product") : (result.get("product")+"-"+result.get("specification")));
            List<Map<String, Object>> mapList = new ArrayList<>();
            List<CheckResultDetailDO> detailDOS = detailDao.list(Long.valueOf(String.valueOf(result.get("id"))));
            for (CheckResultDetailDO detailDO : detailDOS) {
                Map<String, Object> map = new HashMap<>();
                map.put("mainId", detailDO.getMainId());
                map.put("remark", detailDO.getCheckResult());
                map.put("size", detailDO.getSize());
                map.put("formula", detailDO.getFormula());
                map.put("specification", detailDO.getSpecification());
                map.put("id", detailDO.getId());
                map.put("name", detailDO.getCheckItem());
                map.put("projectId", detailDO.getCheckItemId());
                map.put("remarks", detailDO.getRemarks());
                map.put("typeName", detailDO.getCheckType() != null ? detailDO.getCheckType() : "");
                map.put("sample", detailDO.getSample());
                map.put("method", detailDO.getCheckWay());
                map.put("targetValue", detailDO.getTargetValue());
                map.put("statusValue",detailDO.getStatusValue());
                map.put("mode",detailDO.getMode());
                map.put("checkWay",detailDO.getCheckWay());
                if (!ObjectUtils.isEmpty(detailDO.getCheckValue())){
                    map.put("checkValue", JSON.parseArray(detailDO.getCheckValue()));
                }else {
                    map.put("checkValue", new ArrayList<>());
                }
                map.put("checkResult", detailDO.getCheckResult());
                mapList.add(map);
            }
            result.put("detailDOS", mapList);
            return result;
        }
        return null;
    }

    @Override
    public Map<String, Object> printDetailOfResult(Long id) {
        List<CheckResultDetailDOVo> checkResultDetailDOVos = this.listForDetail(id);
        CheckResultDO checkResultDO = dao.get(id);
        CheckResultDetailDOVo zhuRuKou = new CheckResultDetailDOVo();
        CheckResultDetailDOVo houDu = new CheckResultDetailDOVo();
        CheckResultDetailDOVo gaoDu = new CheckResultDetailDOVo();
        CheckResultDetailDOVo kuanDu = new CheckResultDetailDOVo();
        CheckResultDetailDOVo zhongLiang = new CheckResultDetailDOVo();
        CheckResultDetailDOVo rongJi = new CheckResultDetailDOVo();
        CheckResultDetailDOVo waiGuan = new CheckResultDetailDOVo();
        CheckResultDetailDOVo diaoLuo = new CheckResultDetailDOVo();
        CheckResultDetailDOVo louShui = new CheckResultDetailDOVo();
        CheckResultDetailDOVo qiMi = new CheckResultDetailDOVo();
        JSONArray jsonArray = new JSONArray();
        List<CheckResultDetailDOVo> one = new ArrayList<>();
        List<CheckResultDetailDOVo> two = new ArrayList<>();
        List<CheckResultDetailDOVo> three = new ArrayList<>();
        if (!CollectionUtils.isEmpty(checkResultDetailDOVos)) {
            for (CheckResultDetailDOVo aa : checkResultDetailDOVos) {
                String typeDictionaryId = aa.getTypeDictionaryName()==null ? "" : aa.getTypeDictionaryName();
                JSONArray arrays = JSON.parseArray(aa.getCheckValue());
                if (!ObjectUtils.isEmpty(arrays)) {
                    arrays.sort((a,b)->Double.parseDouble(a.toString()) > Double.parseDouble(b.toString()) ? 1 :-1);
                }
                aa.setCheckValue(arrays.toJSONString());
                aa.setCheckResult("合格".equals(aa.getCheckResult()) ? "OK" : "NO");
                switch (typeDictionaryId) {
                    case "检查":
                        //检查
                        //one.add(aa);
                        switch (aa.getCheckItem()){
                            case "漏水试验":
                                louShui = aa;
                                break;
                            case "气密检查":
                                qiMi = aa;
                                break;
                            case "外观检查":
                                waiGuan = aa;
                                break;
                            case "摔落试验":
                                diaoLuo = aa;
                                break;
                        }
                        break;
                    case "颗粒物测定":
                        //颗粒物测定
                        if("0.3 ㎛ ≤ particle".equals(aa.getSize())){
                            two.add(aa);
                        }
                        break;
                    case "注入口内径":
                        if(ObjectUtils.isEmpty(zhuRuKou)){
                            zhuRuKou = aa;
                        }
                        JSONArray array = JSON.parseArray(aa.getCheckValue());
                        if (!ObjectUtils.isEmpty(array)){
                            BigDecimal average = array.stream().collect(CustomCollectors.averagingBigDecimal(i -> new BigDecimal(i.toString()), 2, 2));
                            average.setScale(1,BigDecimal.ROUND_HALF_UP);
                            average.setScale(1,BigDecimal.ROUND_HALF_UP);
                            jsonArray.add(average);
                        }
                        //外观测定
                        //three.add(aa);
                        break;
                    case "厚度":
                        //外观测定
//                        three.add(aa);
                        JSONArray jsonArray1 = new JSONArray();
                        JSONArray array1 = JSON.parseArray(aa.getCheckValue());
                        jsonArray1.add(array1.get(0));
                        jsonArray1.add(array1.get(1));
                        aa.setCheckValue(jsonArray1.toJSONString());
                        houDu = aa;
                        break;
                    case "高度":
                        //外观测定
                        //three.add(aa);
                        gaoDu = aa;
                        break;
                    case "宽度":
                        //外观测定
                        //three.add(aa);
                        kuanDu = aa;
                        break;
                    case "重量":
                        //外观测定
                        //three.add(aa);
                        zhongLiang = aa;
                        break;
                    case "容积":
                        //外观测定
                        //three.add(aa);
                        StringBuffer norm = new StringBuffer(aa.getNorm());
                        norm = norm.insert(aa.getNorm().indexOf("≤")-1,"L");
                        aa.setNorm(norm.toString());
                        rongJi = aa;
                        break;
                }
            }
//            checkResultDetailDOVos.stream().forEach(aa -> {
//
//            });

        }

        zhuRuKou.setCheckItem("注入口内径");
        jsonArray.sort((a,b)->Double.parseDouble(a.toString()) > Double.parseDouble(b.toString()) ? 1 :-1);
        zhuRuKou.setCheckValue(jsonArray.toJSONString());
        three.add(zhuRuKou);
        three.add(houDu);
        three.add(gaoDu);
        three.add(kuanDu);
        three.add(zhongLiang);
        three.add(rongJi);
        one.add(waiGuan);
        one.add(diaoLuo);
        one.add(louShui);
        one.add(qiMi);
        Map<String,Object> head = new HashMap<>();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        head.put("productName",checkResultDO.getProduct());
        head.put("qaManager",checkResultDO.getQualityInspectorName());
        head.put("qaPrepared",checkResultDO.getQualityBearerName());
        head.put("remarks",checkResultDO.getRemarks());
        head.put( "lotNo",checkResultDO.getBatchNo());
        head.put( "date",sdf.format(checkResultDO.getCreateTime()));
        Map<String,Object> result = new HashMap<>();
        result.put( "head",head);
        result.put( "one",one);
        result.put( "two",two);
        result.put( "three",three);
        return result;
    }



    @Override
    public List<CheckResultDetailDOVo> listForDetail(Long mainId) {
        return detailDao.listForDetail(mainId);
    }



    @Override
    public Integer update(CheckResultDO entity) {
        return dao.update(entity);
    }

    @Override
    @Transactional
    public Integer update(CheckResultDto dto) {
        CheckResultDO entity = new CheckResultDO();
        SpringUtils.copyPropertiesIgnoreNull(dto, entity);
        dao.update(entity);
//        detailDao.remove(entity.getId());
        List<Map> maps = JSON.parseArray(dto.getDetailDOS(), Map.class);
        List<CheckResultDetail2VO> detailDOS = this.mapCreateDoMain(maps);
        for (CheckResultDetail2VO detailDO : detailDOS) {
            detailDO.setMainId(entity.getId());
        }
        return detailDao.batchUpdate(detailDOS);
    }

    @Override
    public int batchRemove(Long[] ids) {
        detailDao.batchRemove(ids);
        return dao.batchRemove(ids);
    }

    @Override
    @Transactional
    public int remove(Long id) {
        detailDao.remove(id);
        return dao.remove(id);
    }

    @Override
    public int countForMap(Map<String, Object> params) {
        return dao.countForMap(params);
    }

    @Override
    public List<Map<String, Object>> listForMap(Map<String, Object> param) {
        return dao.listForMap(param);
    }

    @Override
    public List<CheckResultVO> getDetailInfoList(Map<String, Object> param) {
        return dao.getDetailInfoList(param);
    }

    @Override
    public List<CheckResultVO> getDetailInfoList2(Map<String, Object> param) {
        return dao.getDetailInfoList2(param);
    }

    @Override
    public Integer getCountInfoList(Map<String, Object> param) {
        return dao.getCountInfoList(param);
    }
}
